/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Mobilottery.UI.Forms;

import Mobilottery.Interfaces.IAlertCommandListener;
import Mobilottery.AppManager;
import Mobilottery.Constants.Consts;
import Mobilottery.Constants.Consts.Screens;
import Mobilottery.XmlManager.*;
import javax.microedition.lcdui.*;

/**
 *
 * @author WindowsVista
 */
public class FormMyGameInfo extends Form implements CommandListener
{

    int _selectedGameIndex;
    MyGamesDetails _myGamesDetails;

    public FormMyGameInfo(Object p_obj)
    {
        super("My Games");

        Object[] arrObj = (Object[]) p_obj;
        _selectedGameIndex = ((Integer) arrObj[0]).intValue();
        _myGamesDetails = (MyGamesDetails) arrObj[1];

        StringItem si;

        // game name
        si = new StringItem("Name:", _myGamesDetails.GamesNames[_selectedGameIndex]);
        si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
        this.append(si);

        // winning price
        si = new StringItem("Winning Price:", _myGamesDetails.GamesWinningPrices[_selectedGameIndex] + "$");
        si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
        this.append(si);

        if (_myGamesDetails.GamesUserWinningAmounts[_selectedGameIndex] != -1)
        {
            // Date
            si = new StringItem("Date:", _myGamesDetails.GamesDates[_selectedGameIndex]);
            si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
            this.append(si);

            // Transaction ID
            si = new StringItem("Transaction ID:", _myGamesDetails.GamesTransactionsIDs[_selectedGameIndex]);
            si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
            this.append(si);

            // Winning results
            si = new StringItem("Winning results:", _myGamesDetails.GamesWinningResults[_selectedGameIndex]);
            si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
            this.append(si);

            // User Participation info
            si = new StringItem("User Participation info:", _myGamesDetails.GamesParticipationInfos[_selectedGameIndex]);
            si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
            this.append(si);

            // Winning Amount!
            si = new StringItem("Winning Amount:", _myGamesDetails.GamesUserWinningAmounts[_selectedGameIndex] + "$");
            si.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_NEWLINE_AFTER);
            this.append(si);
        }

        Command cmd;
        //cmd = new Command("Select", Command.OK, 0);
        //this.addCommand(cmd);

        cmd = new Command("Back", Command.BACK, 0);
        this.addCommand(cmd);
        this.setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d)
    {
        int cmdType = c.getCommandType();
        if (cmdType == Command.BACK)
        {
            back_Clicked();
        }
    }

    private void back_Clicked()
    {
        AppManager.goToScreen(Screens.MyGames, new Object[]
                {
                    new Integer(_selectedGameIndex),
                    _myGamesDetails
                });
    }
}
